package yf.mall.enums;

import lombok.Getter;

import java.util.Arrays;


/**
 *
 *
 * @date Tue Jul 18 14:30:26 CST 2023
 */
@Getter
public enum AppMaterialFileTypeEnum {


    VEDIO(0, "视频"),


    PICTURE(1, "图片"),


    MUSIC(2, "音频"),


    TEXT(3, "文本");


    int index;
    String value;

    public static String[] names() {
        return Arrays.stream(AppMaterialFileTypeEnum.values()).map(m -> m.getValue()).toArray(String[]::new);
    }

    AppMaterialFileTypeEnum(int index, String value) {
        this.index = index;
        this.value = value;
    }

    public static int nameOf(String name) {
        Integer res = null;
        for (int i = 0; i < names().length; i++) {
            if (names()[i].equals(name)) {
                res = i;
                break;
            }
        }
        return res;
    }

    public static String indexOf(int idx) {
        return AppMaterialFileTypeEnum.values()[idx].getValue();
    }

}
